package com.wangbb.naruto.app.activity; import android.os.Bundle; import android.os.Message; import android.support.v7.widget.Toolbar; import android.view.View; import android.webkit.DownloadListener; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import com.wangbb.naruto.R; import com.wangbb.naruto.app.view.LoadingViewHelper; /** * Created by wangbinbin on 15/5/9. */ public class AboutActivity extends BaseFragmentActivity { private WebView webView; private LoadingViewHelper loadingview; private Toolbar toolbar; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); initView(); initWebview(); initData(); } private void initData() { toolbar.setTitle("����"); toolbar.setNavigationIcon(R.drawable.arrow_left); setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); loadingview.startLoading(); webView.loadUrl("http://naruto-wbb.github.io"); } private void initWebview() { webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } public void onPageFinished(WebView view, String url) { loadingview.loadingSuccess(); } public void onFormResubmission(WebView view, Message dontResend, Message resend) { resend.sendToTarget(); } }); webView.setWebChromeClient(new WebChromeClient() { }); webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { } }); } private void initView() { webView = (WebView) findViewById(R.id.webview); loadingview = new LoadingViewHelper(findViewById(R.id.loading_view)); toolbar = (Toolbar) findViewById(R.id.toolbar); } private void back() { if (webView.canGoBack()) { webView.goBack(); } else { finish(); } } @Override public void onBackPressed() { back(); } @Override public void onPause() {// �̳���Activity super.onPause(); webView.onPause(); } @Override public void onResume() {// �̳���Activity super.onResume(); webView.onResume(); } }